//package com.cssy.yd.logic.service.impl;
//
//import java.util.Date;
//import java.util.List;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.lang.StringUtils;
//import org.apache.log4j.Logger;
//import org.springframework.stereotype.Service;
//
//import com.alibaba.fastjson.JSONArray;
//import com.byd.acegiext.domain.User;
//import com.cssy.yd.dock.entity.Xxm2eJobCompleteDO;
//import com.cssy.yd.dock.service.IXxm2eJobCompleteService;
//import com.cssy.yd.logic.dao.LogicMesWareDAO;
//import com.cssy.yd.logic.dao.LogicMesWareItemDAO;
//import com.cssy.yd.logic.entity.LogicMesWareDO;
//import com.cssy.yd.logic.entity.LogicMesWareItemDO;
//import com.cssy.yd.logic.entity.LogicWhAffDO;
//import com.cssy.yd.logic.service.ILogicMesWareService;
//import com.cssy.yd.logic.service.ILogicWhAffStockService;
//import com.plat.exception.SyBaseException;
//import com.plat.helper.SearchConditions;
//import com.plat.helper.SearchResult;
//import com.plat.util.DateUtils;
//import com.plat.util.GlobalResLoader;
//import com.plat.util.IDCodeTypeUtil;
//import com.plat.util.SessionUtil;
//import com.yuendong.sy.service.code.SyCodeType;
//import com.yuendong.sy.service.code.impl.SyCodeService;
//
//@Service("logicMesWareService")
//public class LogicMesWareServiceImpl implements ILogicMesWareService{
//	private static final Logger logger = Logger.getLogger(LogicMesWareServiceImpl.class);
//	
//	@Resource(name="logicMesWareDAO")
//	private LogicMesWareDAO logicMesWareDAO;
//	
//	@Resource(name="logicMesWareItemDAO")
//	private LogicMesWareItemDAO	logicMesWareItemDAO;
//	
//	@Resource(name = "syCodeService")
//	private SyCodeService syCodeService;
//	
//	@Resource(name = "logicWhAffStockService")
//	private ILogicWhAffStockService logicWhAffStockService;
//	
//	@Resource(name="xxm2eJobCompleteService")
//	private IXxm2eJobCompleteService xxm2eJobCompleteService;
//	
//	@Override
//	public SearchResult findListByExample(SearchConditions scs)
//			throws SyBaseException {
//		SearchResult rs=new SearchResult(scs);
//		List<LogicMesWareDO>  list=logicMesWareDAO.find(scs);
//		rs.setRecordCount(logicMesWareDAO.count(scs));
//		rs.setResults(list);
//		return rs;
//	}
//
//	@Override
//	public Integer delete(String id, User user) throws SyBaseException {
//		
//		return logicMesWareDAO.deleteLogicMesWareDOByPrimaryKey(id);
//	}
//
//	@Override
//	public Integer update(LogicMesWareDO t, User user) throws SyBaseException {
//		t.setVersion(t.getVersion()+1);
//		t.setDuuser(user.getName());
//		t.setDutime(new Date());
//		return logicMesWareDAO.updateLogicMesWareDO(t);
//	}
//
//	@Override
//	public LogicMesWareDO save(LogicMesWareDO t, User user)
//			throws SyBaseException {
//		t.setVersion(Double.parseDouble("1"));
//		t.setDcruser(user.getName());
//		t.setDctime(new Date());
//		t.setId(IDCodeTypeUtil.getId());
//		logicMesWareDAO.insertLogicMesWareDO(t);
//		return t;
//	}
//
//	@Override
//	public LogicMesWareDO findListById(String id) throws SyBaseException {
//		
//		return logicMesWareDAO.findLogicMesWareDOByPrimaryKey(id);
//	}
//
//	@Override
//	public List<LogicMesWareDO> findListByExample(LogicMesWareDO lMesWareDO)
//			throws SyBaseException {
//		return logicMesWareDAO.findListByExample(lMesWareDO);
//	}
//
//	@Override
//	public void mesWareSave(HttpServletRequest request,
//			LogicMesWareDO curAP) throws SyBaseException {
//		try{
//			String itemdata = request.getParameter("itemdata");
//			String type = request.getParameter("type");
//			String transactionDate = request.getParameter("transactionDate");
//			if(StringUtils.isNotBlank(transactionDate)){
//				curAP.setTransactionDate(DateUtils.stringToDate(transactionDate));
//			}
//			
//			curAP.setBillstatus(Short.parseShort(type));
//			List<LogicMesWareItemDO> axxlist=JSONArray.parseArray(itemdata, LogicMesWareItemDO.class);
//			if(curAP.getId()!=null && !"".equals(curAP.getId())){//修改
//				int rt=0;
//				rt=this.update(curAP, SessionUtil.getUser(request));
//				if(0==rt){
//					throw new SyBaseException("您修改的行数据发生改变！请重新打开查看");
//				}
//				if (curAP.getBillstatus() == 3){
//					LogicMesWareDO loi = logicMesWareDAO.findLogicMesWareDOByPrimaryKey(curAP.getId());
//					for (LogicMesWareItemDO lii : axxlist){
//						if (curAP.getBillstatus() == 3){
//							LogicWhAffDO lw = new LogicWhAffDO();
//							lw.setBillCode(loi.getErpwarecode());
//							lw.setBatch(lii.getBatch());
//							lw.setBillType("SC");
//							lw.setCode(lii.getCode());
//							lw.setDcruser(SessionUtil.getUser(request).getName());
//							lw.setDctime(new Date());
//							lw.setName(lii.getName());
//							lw.setSpec(lii.getSpec());
//							lw.setStatus(lii.getState());
//							lw.setWhCode(loi.getWhcode());
//							lw.setWhname(loi.getWhname());
//							lw.setUnit(lii.getUnit());
//							lw.setJunit(lii.getUnit());
//							lw.setQuantity(lii.getReceived());
//							lw.setJquantity(lii.getReceived());
//							logicWhAffStockService.updateWhAffstockQuantity(lw, SessionUtil.getUser(request),true);
//						}
//					}
//				}
//			}else{
//		//			String code=syCodeService.getCode(SyCodeType.DATE_CODE, "SC", "SC");
//					String code=curAP.getMeswarecode();
//					String id = IDCodeTypeUtil.getId();
//					curAP.setErpwarecode(code);
//					curAP.setId(id);
//					curAP.setVersion(Double.parseDouble("1"));
//					curAP.setDcruser(SessionUtil.getUser(request).getName());
//					curAP.setDctime(new Date());
//					logicMesWareDAO.insertLogicMesWareDO(curAP);
//					for (LogicMesWareItemDO lii : axxlist){
//						lii.setId(IDCodeTypeUtil.getId());
//						lii.setMeswareid(id);
//						logicMesWareItemDAO.insertLogicMesWareItemDO(lii);
//					}
//					Xxm2eJobCompleteDO xCompleteDO = new Xxm2eJobCompleteDO();
//					xCompleteDO.setShipNo(curAP.getMeswarecode());
//					xCompleteDO.setProcessCode("2");
//					xxm2eJobCompleteService.update(xCompleteDO, SessionUtil.getUser(request));
//			}
//		}catch(Exception e){
//			logger.error(e.getMessage(), e);
//			throw new SyBaseException(GlobalResLoader.getOpfailed()
//					+ e.getMessage());
//		}
//	}
//
//	@Override
//	public Integer deleteBizRemoved(String id) throws SyBaseException {
//		// TODO Auto-generated method stub
//		return null;
//	}
//
//}
